<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <style type="text/css">
				.form-groups {
				    width: 45%;
				     margin-right: 15px; 
				    margin-left: 15px; 
				    margin-bottom: 15px;  
				}
				.col-lg-9s {
				    width: 65%;
				}
				.left{
					float:left;
				}
				.right{
					float:right;
				}
				.col-lgs{
					width: 35%;
					padding-right: 15px; 
				}
				input{
					text-indent:10px;
					height: 30px;
					width: 80%;
					border-radius:5px;
				}
				input[disabled],input:disabled{
					border:1px solid #DDD;
					background-color:#F5F5F5;
					color:#ACA899;
				}
				.tts{
					margin-right: 30px; 
				}
</style>

<form id="editForm" action="${BASE_PATH}/bus/money/doEdit" method="post" class="form-horizontal">
	<div class="row">
		<div class="form-groups left">
		    <label class="col-lgs control-label left">会员卡号：</label>
		    <div class="col-lg-9s right">
	        	<input type="text" name="card" value="${user.card}" class="form-user" disabled="disabled">
		    </div>
		</div>
		<div class="form-groups right">
		    <label class="col-lgs control-label left">手机号：</label>
		    <div class="col-lg-9s right">
	        	<input type="text" name="phone" id="phone" value="${user.phone}" class="form-user" placeholder="请输入手机号" required maxlength="11" disabled="disabled">
		    </div>
		</div>
	</div>
	<div class="row">
		<div class="form-groups left">
		    <label class="col-lgs control-label left">昵称：</label>
		    <div class="col-lg-9s right">
	        	<input type="text" name="name" value="${user.name}" class="form-user" disabled="disabled">
		    </div>
		</div>
		<div class="form-groups right">
		    <label class="col-lgs control-label left">会员状态：</label>
		    <div class="col-lg-9s right">
		    	<c:if test="${user.state ==0}">
	        		<input type="text" name="state" value="" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.state ==1}">
	        		<input type="text" name="state" value="未登录" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.state ==2}">
	        		<input type="text" name="state" value="未注册" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.state ==3}">
	        		<input type="text" name="state" value="会员" class="form-user"  disabled="disabled">
		    	</c:if>
		    </div>
		</div>
	</div>
	<div class="row">
		<div class="form-groups left">
		    <label class="col-lgs control-label left">年龄：</label>
		    <div class="col-lg-9s right">
	        	<input type="text" name="age" value="${user.age}" class="form-user" disabled="disabled">
		    </div>
		</div>

	</div>
	<div class="row">
		<div class="form-groups left">
		    <label class="col-lgs control-label left">抵扣券：</label>
		    <div class="col-lg-9s right">
	        	<input type="text" name="jkpoint" id="jkpoint" value="${user.jkpoint}"  class="form-user" disabled="disabled">
		    </div>
		</div>
		<div class="form-groups right">
		    <label class="col-lgs control-label left">升级日期：</label>
		    <div class="col-lg-9s right">
	        		<input type="text" name="babyth" value="${user.babythday}" class="form-user"  disabled="disabled">
		    </div>
		</div>
	</div>
	<div class="row">
		<div class="form-groups left">
		    <label class="col-lgs control-label left">惠券：</label>
		    <div class="col-lg-9s right">
	        	<input type="text" name="jypoint" id="jypoint"  value="${user.jypoint}"  class="form-user" disabled="disabled">
		    </div>
		</div>
		<div class="form-groups right">
		    <label class="col-lgs control-label left">所属分公司：</label>
		    <div class="col-lg-9s right">
        		<select id="ssStore" name="store" class="pull-left p-l-5"  style="width:80%;height: 30px;" disabled="disabled" >
					<option value="">请选择分公司</option>
					<c:forEach items="${storeList }" var="seller">
						<option value="${seller.storeid }" <c:if test="${seller.title == user.storeName }">selected</c:if>>${seller.title }</option>
					</c:forEach>
				</select>
		    </div>
		</div>
	</div>
	<div class="row">
		<div class="form-groups left">
		    <label class="col-lgs control-label left">积分：</label>
		    <div class="col-lg-9s right">
	        	<input type="text" name="sppoint" id="sppoint" value="${user.sppoint}"  class="form-user" disabled="disabled">
		    </div>
		</div>
		<div class="form-groups right">
		    <label class="col-lgs control-label left">销售：</label>
		    <div class="col-lg-9s right">
	        		<select id="ssDao" name="toBossOneId" class="pull-left p-l-5" style="width:80%;height: 30px;" disabled="disabled" >
						<c:forEach items="${userList }" var="users">
							<option value="${users.trueName }" <c:if test="${users.id == user.toBossOneId }">selected</c:if>>${users.trueName }</option>
						</c:forEach>
					</select>
		    </div>
		</div>
	</div>
	<div class="row">
	    <div class="form-groups left">
		    <label class="col-lgs control-label left">钱包余额</label>
		    <div class="col-lg-9s left">
	        		<div class="col-lg-9s left">
	        	<input type="text" name="money" id="money" value="${user.money}"  class="form-user" disabled="disabled" style="width: 123%;">
		    </div>
		    </div>
		</div>
		<div class="form-groups right">
		    <label class="col-lgs control-label left">等级：</label>
		    <div class="col-lg-9s right">
		    	<c:if test="${user.taici ==0}">
	        		<input type="text" name="taici" value="" class="form-user"  disabled="disabled">
		    	</c:if>
	        	<c:if test="${user.taici ==1}">
	        		<input type="text" name="taici" value="会员" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.taici ==2}">
	        		<input type="text" name="taici" value="黄金" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.taici ==3}">
	        		<input type="text" name="taici" value="白金" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.taici ==4}">
	        		<input type="text" name="taici" value="经纪人" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.taici ==5}">
	        		<input type="text" name="taici" value="营业部" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.taici ==6}">
	        		<input type="text" name="taici" value="分公司" class="form-user"  disabled="disabled">
		    	</c:if>
		    	<c:if test="${user.taici ==7}">
	        		<input type="text" name="taici" value="公司" class="form-user"  disabled="disabled">
		    	</c:if>
		    </div>
		</div>
	</div>
	<div class="row">
		<div class="form-groups right">
			<!-- <span class="btn btn-primary tts" onclick="jfedit();" type="button">积分修改</span> -->
			<span class="btn btn-primary tts" onclick="edit();" type="button">修改</span>
			<button class="btn btn-primary tts" type="submit" autocomplete="off">保存</button>
			<button class="btn btn-default" type="button" onclick="javascript:showDialog.close();" autocomplete="off">取消</button>
		</div>
	</div>
	<input type="hidden" name="userid" value="${user.id}"/>
</form>
<script type="text/javascript">

$(function(){
	//初始化表单验证
	$("#editForm").validate({
		rules:{
			phone: {
				isMobile:true
			}
		},
		messages:{
			phone: {required: "请输入用户名",isMobile: "请输入正确的手机号码"},
		},
		submitHandler:function(form){
			$(form).ajaxSubmit({
				success:function(result){
					switch(result.flag){
					case -1:
						Kit.alert("保存失败");showDialog.close();return;
					case 2:
						Kit.alert("手机号不可用");showDialog.close();return;
					case 0:
						onEditSuccess(result.object);
						showDialog.close();
					}
				}
			});
		}
	});
});

$("#ssStore").change(function(){
var	store=$("#ssStore").val();
	  $.ajax({
           type: "POST",
           url: "${BASE_PATH}/bus/money/chooseDao",
           data: {"store" : store},
           dataType: "json",
           traditional: true,
           success: function(data){
          	   $("#ssDao").empty(); 
               $("#ssDao").append("<option value=''>请选择营业部</option>");
               for(var i=0; i<data.object.length;i++){
              	 $("#ssDao").append("<option value='"+data.object[i].trueName+"'>"+data.object[i].trueName+"</option>");
               }
               $("#ssDao").selectpicker("refresh");
           }
       });
    });
    function jfedit(){
    	$("#jkpoint").removeAttr("disabled");
    	$("#jypoint").removeAttr("disabled");
    	$("#sppoint").removeAttr("disabled");
    }
    function edit(){
    	$("#phone").removeAttr("disabled");
     	$("#ssStore").removeAttr("disabled");
    	$("#ssDao").removeAttr("disabled");
    }
</script>